<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {{template "header"}}
    <title>addjob</title>
    <style type="text/css">
        .layui-laydate-content > .layui-laydate-list {
            padding-bottom: 0px;
            overflow: hidden;
        }

        .layui-laydate-content > .layui-laydate-list > li {
            width: 50%
        }

        .merge-box .scrollbox .merge-list {
            padding-bottom: 5px;
        }

        .layui-form-select {
            width: 90% !important;
        }
    </style>
</head>
<body>
<div class="layui-container">
    <div class="layui-row" style="margin-top: 50px;text-align: center">
        <form class="layui-form layui-form-pane" enctype="multipart/form-data">
            <div id="hidden_edit">
                <input type="text" hidden="hidden" name="id" value="{{.id}}">
                <input type="text" hidden="hidden" name="status" value="{{.status}}">

            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 20%">发送人姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="user_from_name" style="width: 90%" value="{{.user_from_name}}"
                           lay-verify="required"
                           placeholder="发送短信人姓名"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 20%">发送时间</label>
                <div class="layui-input-block">
                    <input type="text" name="time" id="time" style="width: 90%" value="{{.time}}"
                           lay-verify="required"
                           placeholder="发送时间"
                           class="layui-input">

                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 20%">收信人姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="user_to_name" style="width: 90%" value="{{.user_to_name}}"
                           lay-verify="required"
                           placeholder="请输入收信人姓名"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 20%">收信人电话</label>
                <div class="layui-input-block">
                    <input type="text" name="user_to_phone" style="width: 90%" value="{{.user_to_phone}}"
                           lay-verify="required"
                           placeholder="请输入收信人电话"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 20%">短信类型</label>
                <div class="layui-input-block" style="text-align: -webkit-left;text-align: left;">
                    <input type="radio" name="smstype" value="1" title="名言警句"  {{if eq .smstype   1}} checked="" {{end}}>
                    <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
                        <div>名言警句</div>
                    </div>
                    <input type="radio" name="smstype" value="2" title="土味情话"  {{if eq .smstype   2}} checked="" {{end}}>
                    <div class="layui-unselect layui-form-radio layui-form-radioed"><i
                                class="layui-anim layui-icon layui-anim-scaleSpring"></i>
                        <div>土味情话</div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item" style="text-align: center">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="savebt">保存</button>
            </div>
        </form>
    </div>
</div>
{{template "footer"}}
<script>
    layui.use('form', function () {
        var form = layui.form;

        //各种基于事件的操作，下面会有进一步介绍
        //监听提交
        form.on('submit(savebt)', function (data) {
            //console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
            ajaxPostNoAsync("/AddOne", $(data.form).serialize(), function (datastr) {
                var dataInner = eval('(' + datastr + ')');
                console.log("返回内容", dataInner, typeof (dataInner), "dataInner.code=", dataInner.code, dataInner.message)
                if (dataInner.code == "success") {
                    successMsg('操作成功!')
                    setTimeout(function () {
                        table_layer_close()
                        return false;
                    }, 2000)
                } else {
                    console.log("1")
                    failMsg('操作失败!' + dataInner.message)
                    return false;
                }
            })


            return false;
        });

        form.verify({
            domain: function (value, item) { //value：表单的值、item：表单的DOM对象
                //todo:前端用正则验证 abc.xyz
                //if (value.indexOf(".") > 1 && value.split(".").length == 2) {
                // } else {
                //    return '请输入顶级域名,如 baidu.com ';
                //}
                if (IsURL(/(\/+|^)[a-z]{1,}\.[a-z]{1,}(\/+|$)/, value)) {

                } else {
                    return '请输入顶级域名,如 baidu.com ';
                }
            },
            cron: function (value, itme) {
                //todo:前端用正则校验cron 不可用 ,后台校验生效.
                if (!cronValidate(value)) {
                } else {
                    return '请输入合法的cron表达式';
                }
            }
        });
    });

    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#time', //指定元素
            type: 'time'
            , format: 'HH:mm'
            , btns: ['clear', 'confirm']
            , ready: formatminutes
        });
    });

    function formatminutes(date) {
        var aa = $(".laydate-time-list li ol")[1];
        var showtime = $($(".laydate-time-list li ol")[1]).find("li");
        for (var i = 0; i < showtime.length; i++) {
            var t00 = showtime[i].innerText;
            /*  if (t00 != "00" && t00 != "20" && t00 != "30" && t00 != "40" && t00 != "50") {
                  showtime[i].remove()
              }*/
        }
        $($(".laydate-time-list li ol")[2]).find("li").remove();  //清空秒
    }
</script>
</body>
</html>